import { RoleButtonExend, RoleMenuExend, RoleUserInput, UpdateIsOpenInPut } from '@/model/public/public';
import Http from '../http';
import { SysRole } from '@/model/role/role';
export const getAllRoleTreeList = async function () {
  return await Http.get('/api/SysRole/GetAllRoleTreeList');
}

//新增角色
export const insert = function (sysRole: SysRole) {
  return Http.post('/api/SysRole/Insert', sysRole)
}

//编辑角色
export const update = function (sysRole: SysRole) {
  return Http.post('/api/SysRole/Update', sysRole)
}

//设置角色是否启用
export const SetRoleIsOpen = function (updateIsOpenInPut: UpdateIsOpenInPut) {
  return Http.post('/api/SysRole/SetRoleIsOpen', updateIsOpenInPut)
}

//获取树形结构角色数据
export const getRoleTree = async function (params?: { corporationKey?: string, systemKey?: string }) {
  return await Http.get('/api/SysRole/GetRoleTree', params);
}

//保存角色权限--菜单权限
export const saveRoleAuthority = function (roleMenuExend: RoleMenuExend) {
  return Http.post('/api/SysRole/SaveRoleAuthority', roleMenuExend)
}

//保存角色权限--按钮权限
export const saveRoleButtonAuthority = function (roleButtonExend: RoleButtonExend) {
  return Http.post('/api/SysRole/SaveRoleButtonAuthority', roleButtonExend)
}

//根据角色获取所属菜单key
export const getMenuKeyByRoleId = async function (params?: { roleId?: number | undefined | string,isContainSubordinate:boolean }) {
  return await Http.get('/api/SysRole/GetMenuKeyByRoleId', params);
}

//根据角色id获取权限按钮
export const getButtonKeyByRoleId = async function (params?: { roleId?: number | undefined | string,isContainSubordinate:boolean }) {
  return await Http.get('/api/SysRole/GetButtonKeyByRoleId', params);
}

//绑定角色用户
export const BindRoleUser = function (roleUserInput: RoleUserInput) {
  return Http.post('/api/SysRole/BindRoleUser', roleUserInput)
}